//replace by your package name
package exercise.tute13kengine.version1;

import kengine.version1.*;
import java.io.File;
import java.util.Arrays;

/**
 * @overview 
 *  A class to run KEngine version 1.0 and print suitable messages.
 */
public class EngineMain {
    
  /**
   * The main method
   * @effects
   *          initialise an Engine
   *          invoke tasks designated to an engine
   *          print suitable messages on the console
   */
  public static void main(String[] args) {
    /*
     * initialise an engine
     */
    System.out.println("KEngine version 1.0");
    Engine eng = new Engine();

    /*
     * perform tasks
     */

    // the test data directory
	// Change directory below to your actual folder.
    String testDirUrl = "file://D:/testData";

    // add docs from the data directory
    System.out.println("Adding docs from URL: " + testDirUrl);
    try {
      eng.addDocs(testDirUrl);
    } catch (Exception e) {
      System.err.println("Error: " + e.getMessage());
      // e.printStackTrace();
    }

    // findDoc: not implemented in this version

    // query: expect to throw exception here as this is not yet implemented
    String[] keys = { "sinh" };
    Query q;
    try {
      System.out.println("Querying using keywords: " + Arrays.toString(keys));
      q = eng.queryFirst(keys[0]);
    } catch (Exception e) {
      System.err.println("*Expected* Error: " + e.getMessage());
    }
  }
}
